package net.hn.hnms.biz.cockpit.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.hn.hnms.biz.cockpit.domain.AutomaticSystem;
import net.hn.hnms.biz.cockpit.domain.MineCompositeIndicator;
import net.hn.hnms.biz.cockpit.mapper.AutomaticSystemMapper;
import net.hn.hnms.biz.cockpit.mapper.MineCompositeIndicatorMapper;
import net.hn.hnms.biz.cockpit.service.IAutomaticSystemService;
import net.hn.hnms.biz.cockpit.service.IMineCompositeIndicatorService;
import org.springframework.stereotype.Service;

@Service
public class MineCompositeIndicatorServiceImpl extends ServiceImpl<MineCompositeIndicatorMapper, MineCompositeIndicator> implements IMineCompositeIndicatorService {
    @Override
    public MineCompositeIndicator getMineralInfo(String mineCode) {
        MineCompositeIndicator result = new MineCompositeIndicator();
        MineCompositeIndicator mineCompositeIndicator = baseMapper.selectOne(new LambdaQueryWrapper<MineCompositeIndicator>().eq(MineCompositeIndicator::getMineCode, mineCode).orderByDesc(MineCompositeIndicator::getCheckPeriod).last("limit 1"));
        if (mineCompositeIndicator != null) {
            BeanUtil.copyProperties(mineCompositeIndicator, result);
        }
        return result;
    }
}
